//
//  ProjectExperienceTableViewCell.m
//  MyProject
//
//  Created by jiaming yan on 2017/9/12.
//  Copyright © 2017年 yanjiaming. All rights reserved.
//

#import "ProjectExperienceTableViewCell.h"

@implementation ProjectExperienceTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.editButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
}
-(void)setProjectArr:(NSArray *)projectArr{
    
    for (UIView *subViews in self.backView.subviews) {
        [subViews removeFromSuperview];
    }
    
    CGFloat beginHeight = 18;
//    if (projectArr.count == 0) {
//        height = 60;
//    }else{
//        
//    }
    for (NSInteger i = 0 ; i < projectArr.count; i++) {
        ProjectModel *model = projectArr[i];
        UIImageView *img = [[UIImageView alloc]initWithImage:IMAGE(@"圆")];
        img.frame = CGRectMake(15, beginHeight + 2*(i+1), 11, 11);
        [self.backView addSubview:img];
        
        
        UILabel *timeLab = [[UILabel alloc]initWithFrame:CGRectMake(41, beginHeight, kScreenWidth - 30 - 41 - 15, 18)];
        timeLab.font = [UIFont fontWithName:@"PingFangSC-Regular" size:12];
        timeLab.textAlignment = NSTextAlignmentLeft;
        timeLab.textColor = UIColorFromRGB(0x485053);
        [self.backView addSubview:timeLab];
        timeLab.text = [NSString stringWithFormat:@"%@-%@",model.startTime,model.endTime];
        
        UILabel *nameLab = [[UILabel alloc]initWithFrame:CGRectMake(41, timeLab.mj_y + timeLab.mj_h + 10, kScreenWidth - 30 - 41 - 15, 18)];
        nameLab.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15];
        nameLab.textAlignment = NSTextAlignmentLeft;
        nameLab.textColor = UIColorFromRGB(0x485053);
        [self.backView  addSubview:nameLab];
        nameLab.text = [NSString stringWithFormat:@"%@",model.projectName];
        
        UILabel *detailLab = [[UILabel alloc]initWithFrame:CGRectMake(41, nameLab.mj_y + nameLab.mj_h + 10, kScreenWidth - 30 - 41 - 15, 18)];
        detailLab.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14];
        detailLab.textAlignment = NSTextAlignmentLeft;
        detailLab.textColor = UIColorFromRGB(0x485053);
        detailLab.numberOfLines = 0;
        [self.backView addSubview:detailLab];
        detailLab.text = [NSString stringWithFormat:@"项目职责:%@",model.duty];
        [detailLab sizeToFit];
        
//        UILabel *detailDesLab = [[UILabel alloc]initWithFrame:CGRectMake(41, detailLab.mj_y + detailLab.mj_h + 7, kScreenWidth - 130, 17)];
//        detailDesLab.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14];
//        detailDesLab.textAlignment = NSTextAlignmentLeft;
//        detailDesLab.textColor = UIColorFromRGB(0x485053);
//        [self.backView addSubview:detailDesLab];
//        detailDesLab.text = model.projectDescribe;
//        [detailDesLab sizeToFit];
        
 
        
       beginHeight =  detailLab.mj_y + detailLab.mj_h + 26;
    }
    self.backHeight.constant = beginHeight;
    if (projectArr.count == 0) {
        self.backHeight.constant = 60;
    }else{
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(19.5, 24 , 2, beginHeight - 20)];
        line.backgroundColor = UIColorFromRGB(0xD9F3F6);;
        [self.backView addSubview:line];
        [self.backView sendSubviewToBack:line];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
